home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 June / MacFormat 25.iso / Shareware City / Developers / BoxMaker++ / Monochromize ƒ / grafport.cp next >
Encoding:
Text File  |  1995-01-20  |  2.5 KB  |  107 lines  |  [TEXT/KAHL]

  1. #include <stdlib.h>
  2.  
  3. #include <Windows.h>
  4. #include <QDOffscreen.h>
  5.  
  6. #include <Fonts.h>
  7. #include <Packages.h>
  8. #include <SegLoad.h>
  9. #include <ToolUtils.h>
  10. #include <TextEdit.h>
  11.  
  12. #include "grafport.h"
  13.  
  14. const grafport *grafport::currentport = 0;
  15.  
  16. grafport::~grafport()
  17. {
  18.     if( currentport == this)
  19.     {
  20.         //
  21.         // about to delete the current port. To be safe,
  22.         // set the current port to something else.
  23.         //
  24.         SetPort( qd.thePort);
  25.         currentport = 0;
  26.     }
  27. }
  28.  
  29. void grafport::use() const
  30. {
  31.     if( currentport != this)
  32.     {
  33.         currentport = this;
  34.         SetGWorld( myGWorldPtr, myGDHandle);
  35.         // CheckForError( QDError(), "SetGWorld");
  36.     }
  37. }
  38.  
  39. void grafport::copyfrom( const grafport &source, const Rect &origRect,
  40.             const Rect &destRect, const short mode, const RgnHandle maskRgn) const
  41. {
  42.     use();
  43.     CopyBits( (BitMapPtr)(source.myPix), (BitMapPtr)myPix,
  44.                         &origRect, &destRect, mode, maskRgn);
  45. }
  46.  
  47. void grafport::copyfrom( const grafport &source, const Rect &origRect,
  48.                         const short mode, const RgnHandle maskRgn) const
  49. {
  50.     use();
  51.     CopyBits( (BitMapPtr)(source.myPix), (BitMapPtr)myPix,
  52.                         &origRect, &myRect, mode, maskRgn);
  53. }
  54.  
  55. void grafport::copyfrom( const grafport &source, const grafport &mask,
  56.                     const short mode, const RgnHandle maskRgn) const
  57. {
  58.     use();
  59.     CopyDeepMask( (BitMapPtr)(source.myPix), (BitMapPtr)(mask.myPix), (BitMapPtr)myPix,
  60.                     &source.myRect, &mask.myRect, &myRect, mode, maskRgn);
  61. }
  62.  
  63. void grafport::copyfrom( const grafport &source, const grafport &mask, const Rect &origRect,
  64.                     const Rect &maskRect, const Rect &destRect,
  65.                     const short mode, const RgnHandle maskRgn) const
  66. {
  67.     use();
  68.     CopyDeepMask( (BitMapPtr)(source.myPix), (BitMapPtr)(mask.myPix), (BitMapPtr)myPix,
  69.                         &origRect, &maskRect, &destRect, mode, maskRgn);
  70. }
  71.  
  72. void grafport::scroll( short dh, short dv) const
  73. {
  74.     use();
  75.     RgnHandle updateRgn = NewRgn();
  76.     ScrollRect( &myGWorldPtr->portRect, dh, dv, updateRgn);
  77.     DisposeRgn( updateRgn);
  78. }
  79.  
  80. PicHandle grafport::getPICT() const
  81. {
  82.     use();
  83.     PicHandle thePICT = OpenPicture( &myGWorldPtr->portRect);
  84.     CopyBits( (BitMapPtr)myPix, (BitMapPtr)myPix, &myRect, &myRect, srcCopy + ditherCopy, 0L);
  85.     ClosePicture();
  86.     return thePICT;
  87. }
  88.  
  89. void grafport::setentries( short start, short count, ColorSpec *theTable) const
  90. {
  91.     use();
  92.     ::SetEntries( start, count, theTable);
  93. }
  94.  
  95. void grafport::SetColorTable( short resID) const
  96. {
  97.     CTabHandle theColorTable = GetCTable( resID);
  98.     SetColorTable( theColorTable);
  99. }
  100.  
  101. void grafport::SetColorTable( CTabHandle theColorTable) const
  102. {
  103.     DisposCTable( myPix->pmTable);
  104.     myPix->pmTable = theColorTable;
  105.     GDeviceChanged( myGDHandle);
  106. }
  107.